package com.weilan.ark3.read;

import com.weilan.ark3.buffer.MsgQueue;
import com.weilan.ark3.entity.ControlRtu;

import java.util.HashMap;
import java.util.List;

import static com.weilan.ark3.buffer.OverallSituation.com1MessgeRank1;
import static com.weilan.ark3.buffer.OverallSituation.tcpMessgeRank1;

public class Message {

    //报文初始化
    public static void Message_Init(List<ControlRtu>... messge) {
        //先判断集合是否为空
        for (int i = 0; i < messge.length; i++) {
            if (!messge[i].isEmpty()) {//如果集合不为空
                List<ControlRtu> controlRtus = messge[i];
                ControlRtu controlRtu = controlRtus.get(0);
                Integer rank = controlRtu.getRank();
                if (rank == 1) {//一级报文
                    for (int j = 0; j < 4; j++) {
                        controlRtus.forEach(e -> {
                            MsgQueue.writeToQueue(e);
                        });
                    }
                }
                if(rank == 2){//二级报文
                    for (int j = 0; j < 1; j++) {
                        controlRtus.forEach(e -> {
                            MsgQueue.writeToQueue(e);
                        });
                    }
                }
            }
        }
    }
}
